const {
  _request
} = require('../utils/request');
const {
  clearEmptyKey
} = require('../utils/clearEmptyKey')
export function wxLogin(phoneNumber) {
  return new Promise((resolve, reject) => {
    wx.login({
      success: (data) => {
        const params = {
          jsCode: data.code,
          phoneNumber
        }

        clearEmptyKey(params)
        _request({
          url: '/app/wxLoginByPhoneNumber',
          deleteToken: true,
          params
        }).then(res => {
          resolve(res)
        }).catch(err => {
          reject(err)
        })
      },
      fail: err => {
        reject(err)
      }
    })
  })
}

export function bind_account(params) {
  return _request({
    url: '/app/bind_account',
    deleteToken: true,
    params
  })
}

export function sendSms(params) {
  return _request({
    url: '/app/sendSms',
    deleteToken: true,
    params
  })
}